package com.zqxq.lottery.controller.user;

import com.zqxq.common.constant.Result;
import com.zqxq.common.enums.CodeEnum;
import com.zqxq.lottery.entity.vo.user.UserWindowMsgVO;
import com.zqxq.lottery.service.user.IUserWindowMsgService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
public class UserWindowMsgController extends UserBaseController{

    @Autowired
    private IUserWindowMsgService userWindowMsgService;
    @ApiOperation("获取分页信息")
    @RequestMapping(value="/windowMsg/query")
    public Result<List<UserWindowMsgVO>> queryUserWindowMsgPage(@RequestParam("userId") String userId){
        Result<List<UserWindowMsgVO>> result = new Result();
        try {
            List<UserWindowMsgVO> list = userWindowMsgService.queryList(userId);
            result.setData(list);
        }catch (Exception e) {
            log.error("queryUserWindowMsgPage is error!", e);
        }
        return result;
    }

    @PostMapping("/windowMsg/edit")
        public Result updateWindowMsg(@RequestParam("ids") String ids){
        if (StringUtils.isEmpty(ids)) {
            return new Result(CodeEnum.FAIL_100002.getCode(), "消息id不能为空");
        }
        userWindowMsgService.updateWindowMsg(ids);
        return new Result();
    }


}
